package com.zk.bcutil;

import java.util.Properties;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import webservice.BCWebservice;

import com.zk.client.BC_OA_GETUSERINFO;


/**
 * WebService工具类
 * @author Anpengfei
 *
 */
public class WSUtil {

	private static JaxWsProxyFactoryBean orgProxy;	//	机构信息推送服务客户端代理
	
	private static JaxWsProxyFactoryBean userProxy;	//	人员信息推送服务客户端代理
	
	private static JaxWsProxyFactoryBean factory;	
	
	
	
	private static String groupServiceUrlMut; //机构科室批量推送 http://192.168.1.113:30008/services/TCM_PLAT_21?wsdl
	private static String userServiceUrlMut;//人员批量推送 http://192.168.1.113:30009/services/TCM_PLAT_22?wsdl
	private static String groupServiceUrl = "http://10.41.50.22:8080/ESB/webService/bcWebService?wsdl";
	private static String userServiceUrl;
	
	
	
	
	/**
	 * 获取推送机构信息服务客户代理
	 * @return 构信息服务客户代理
	 */
	public static BC_OA_GETUSERINFO getPushOrganizationClient() {
		Object service = createClientProxy(
				orgProxy, groupServiceUrl, BCWebservice.class);
		return (BC_OA_GETUSERINFO)service;
	}
	
	
	
	/**
	 * 创建客户端服务代理
	 * @param proxy	WebService代理类
	 * @param serviceUrl	服务地址
	 * @param serviceClass	接口服务类
	 * @return	客户端服务代理
	 */
	private static Object createClientProxy(JaxWsProxyFactoryBean proxy, String serviceUrl, Class<?> serviceClass) {
		if(proxy == null) {
			proxy = new JaxWsProxyFactoryBean();
			proxy.setAddress(serviceUrl);
			proxy.setServiceClass(serviceClass);
		}
	
		return proxy.create();
	}
}
